package com.zhongxi.guoyuan.view.rewardCoin;

import android.os.Bundle;
import android.util.SparseArray;

import com.zhongxi.guoyuan.base.BaseFragment;
import com.zhongxi.guoyuan.fragment.hmfragment.OneMBestPriceFragment;
import com.zhongxi.guoyuan.fragment.hmfragment.OneMNewFragment;
import com.zhongxi.guoyuan.fragment.hmfragment.OneMSalesGoodsFragment;

/**
 * Created by Administrator on 2017/10/16.
 */

public class ItemOneHFragmentFactory {

    static SparseArray<BaseFragment> fragmentMap=new SparseArray<>();

    public static BaseFragment create(int position, String id, String trim){
        BaseFragment fragment=fragmentMap.get(position);
        if (fragment==null){
            switch (position){
                case 0:
                    fragment=new OneMNewFragment();
                    break;
                case 1:
                    fragment=new OneMSalesGoodsFragment();
                    break;
                case 2:
                    fragment=new OneMBestPriceFragment();
                    break;
            }
            if (fragment!=null){
                fragmentMap.put(position,fragment);
            }
        }
        Bundle args = new Bundle();
        args.putString("id", id);
        args.putString("trim", trim);
        fragment.setArguments(args);
        return fragment;
    }
}
